package com.ophiux.common.utils;

import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;

public class StringUtil {
	public static boolean isEmpty(String str) {
		return (str == null) || (str.equals("")) || (str.equals("null"));
	}

	public static String inputStream2String(InputStream in) {
		if (in == null) {
			return "";
		}
		StringBuffer out = new StringBuffer();
		byte[] b = new byte[4096];
		try {
			int n;
			while ((n = in.read(b)) != -1) {
				out.append(new String(b, 0, n, "UTF-8"));
			}
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
			try {
				in.close();
			} catch (IOException e2) {
				e2.printStackTrace();
			}
		} catch (IOException e) {
			e.printStackTrace();
			try {
				in.close();
			} catch (IOException e2) {
				e2.printStackTrace();
			}
		} finally {
			try {
				in.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return out.toString();
	}
}